

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link href="/ssm/consumer/css/style.css" rel='stylesheet' type='text/css' />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!--webfonts-->
		<!--//webfonts-->
	</head>

	<body>
		<div class="main" align="center">
			<div class="header">
				<h1>修改个人资料</h1>
			</div>
			<p></p>
			<form method="post" action="">
				<input type="hidden" name="op" value="regist" />
				<input style="display: none;" type="text" id="id" required="required"/>
				<ul class="left-form">
					<li>
						<input readonly="readonly" type="text" id="username" placeholder="用户名" required="required"/>
						<a href="#" class="icon ticker"> </a>
						<div class="clear"> </div>
					</li>
					<li>
						<input type="text" id="cellphone" placeholder="手机号" required="required"/>
						<a href="#" class="icon ticker"> </a>
						<div class="clear"> </div>
					</li>
					<li>
						<input type="text" id="email" placeholder="邮箱" required="required"/>
						<a href="#" class="icon ticker"> </a>
						<div class="clear"> </div>
					</li>
					<li>
						<input type="text" id="address" placeholder="联系地址" required="required"/>
						<a href="#" class="icon ticker"> </a>
						<div class="clear"> </div>
					</li>
					<li>
						<input type="text" id="nickname" placeholder="昵称" required="required"/>
						<a href="#" class="icon ticker"> </a>
						<div class="clear"> </div>
					</li>
					<li>
						<input type="password" id="password" placeholder="密码" required="required"/>
						<a href="#" class="icon into"> </a>
						<div class="clear"> </div>
					</li>
					<li>
						<input type="password" id="repassword" placeholder="确认密码" required="required"/>
						<a href="#" class="icon into"> </a>
						<div class="clear"> </div>
					</li>
					
					<li>
						<input type="submit" id="submitReg" value="立即修改">
						<div class="clear"> </div>
					</li>
					<li>
						<a href="javascript:history.go(-1);" style="color: green;">返回</a>
					</li>
			</ul>

			<div class="clear"> </div>

			</form>

		</div>
		<!-----start-copyright---->

		<!-----//end-copyright---->
		<script type="text/javascript" src="/ssm/consumer/js/jquery.min.js"></script>
		<script type="text/javascript">
		$("#submitReg").click(function(){
				var id = $("#id").val();
			   var username = $("#username").val();
			   var cellphone = $("#cellphone").val();
			   var real_name = $("#nickname").val();
			   var password = $("#password").val();
			   var repassword = $("#repassword").val();
			   var address = $("#address").val();
			   var email = $("#email").val();
			   if(username&&cellphone&&password&&repassword&&address){
				   if(password!=repassword){
					   alert("两次密码不一致");
					   return false;
				   }
			   		var qUrl="/ssm/consumer/save.do";
					 var postData = {
							 	id:id,
				                username : username,
				                password : password,
				                real_name : real_name,
				                cellphone :cellphone ,
				                address:address,
				                email:email
				            };
					 	
			            $.post(qUrl,postData,function(res){
			             if(res.code=="01"){
			                 alert("修改成功");
			                 //刷新父页面
			                 location.href="/ssm/consumer/login.html";
			             }else{
			            	 alert(res.body);
			             }
		            })
						 
				   
			   }else{
					alert("请填写完整");		   
			   }
			   return false;
		   })
		   
		   
	    getUserInfo();
		function  getUserInfo(){
		    $.ajax({
		        url:"/ssm/consumer/loginInfo.do",
		        type:"POST",
		        dataType:"json",
		        success:function(data){
		           var info = data.body;
		           if(info==null){
		        	   location.href="/ssm/consumer/login.html";
		        	   return;
		           }
		           $("#username").val(info.username);
				   $("#cellphone").val(info.cellphone);
				   $("#nickname").val(info.real_name);
				   $("#password").val(info.password);
				   $("#address").val(info.address);
				   $("#email").val(info.email);
				   $("#id").val(info.id);
		    	} 
	        })
		 }
		
		</script>
	</body>
	
</html>